package com.epam.kozich;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.epam.kozich.dao.BookDAO;
import com.epam.kozich.dao.OrderDAO;
import com.epam.kozich.dao.PersonDAO;
import com.epam.kozich.model.Book;
import com.epam.kozich.model.Order;
import com.epam.kozich.model.Person;


public class Runner {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext("resources/config.xml");
		
		BookDAO bookDAO = (BookDAO) context.getBean("BookDAO");
		PersonDAO personDAO = (PersonDAO) context.getBean("PersonDAO");
		OrderDAO orderDAO = (OrderDAO) context.getBean("OrderDAO");
		
		Person person = new Person();
		person.setLogin("MonStar");
		person.setPassword("07760776");
		
		Person person2 = new Person();
		
		
		
		Book book2 = new Book();
		book2.setName("Harry Potter");
		bookDAO.addBook(book2);
		
		
		
		Order order = new Order();
		order.setPerson(person);
		List<Book> listBook = new ArrayList<Book>();
		listBook.add(book2);
		order.setBooks(listBook);
		
		
		orderDAO.save(order);
		System.out.println(personDAO.outputBannedPerson());
		System.out.println(bookDAO.getAllBooks());
		//System.out.println(bookDAO.get());
		
		
	}

}
